package com.hoshiicloud.payment.config;

import com.hoshiicloud.payment.sdk.wxpay.IWXPayDomain;
import com.hoshiicloud.payment.sdk.wxpay.WXPayConfig;
import com.hoshiicloud.payment.sdk.wxpay.WXPayDomain;
import lombok.Data;
import org.springframework.stereotype.Component;

import java.io.InputStream;

@Data
@Component
public class WeixinConfig extends WXPayConfig {

    private String appID="wx019c1a221da41633";

    private String mchID;

    private String key;

    private InputStream certInputStream;

    public InputStream getCertInputStream() {
        return certInputStream;
    }

    public void setCertInputStream(InputStream certInputStream) {
        this.certInputStream = certInputStream;
    }

    public WeixinConfig(String appID, String mchID){
        this.appID=appID;
        this.mchID=mchID;
    }

    public WeixinConfig(String appID,String mchID,String key){
        this.appID=appID;
        this.mchID=mchID;
        this.key=key;
    }

    private WeixinConfig(){

    }

    public void setAppID(String appID) {
        this.appID = appID;
    }

    public void setMchID(String mchID) {
        this.mchID = mchID;
    }
    @Override
    public void setKey(String key) {
        this.key = key;
    }

    /**
     * 获取 App ID
     *
     * @return App ID
     */
    @Override
    public String getAppID() {
        return appID;
    }

    /**
     * 获取 Mch ID
     *
     * @return Mch ID
     */
    @Override
    public String getMchID() {
        return mchID;
    }

    /**
     * 获取 API 密钥
     *
     * @return API密钥
     */
    @Override
    public String getKey() {
        return key;
    }



    /**
     * 获取商户证书内容
     *
     * @return 商户证书内容
     */
    @Override
    public InputStream getCertStream() {
        return certInputStream;
    }

    /**
     * 获取WXPayDomain, 用于多域名容灾自动切换
     *
     * @return
     */
    @Override
    public IWXPayDomain getWXPayDomain() {
        return WXPayDomain.instance();
    }
}
